unit UModule_Entry_Siswa_Absensi;

interface

uses
  soap_sis_entry_siswa_absensi,
  Dialogs,
  Controls,
  SysUtils,
  Classes,
  InvokeRegistry,
  Rio,
  XSBuiltIns,
  SOAPHTTPClient,
  ActnList;

type
  TModule_Entry_Siswa_Absensi = class(TDataModule)
    AL01: TActionList;
    HTTPRIO1: THTTPRIO;
    PCommon_Daftar_Subject: TAction;
    PFile_Simpan: TAction;
    PMenu_Entry_Absensi: TAction;
    procedure HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
    procedure PCommon_Daftar_SubjectExecute(Sender: TObject);
    procedure PFile_SimpanExecute(Sender: TObject);
    procedure PMenu_Entry_AbsensiExecute(Sender: TObject);
  private
    FMasterSiswa_Combo:         TInfoDaftarSiswa;
    FMasterGuru_Combo:          TInfoDaftarGuru;
    FMasterMapel_Combo:         TDataMapel;
    FMasterAbsensiStatus_Combo: TInfoDaftarAbsensiStatus;
    procedure Assign_LoginInfo;
  public
    procedure Assign_Action;
  end;

var
  Module_Entry_Siswa_Absensi: TModule_Entry_Siswa_Absensi;

implementation

uses
  UMainApplication,
  UUser;
{$R *.dfm}

procedure TModule_Entry_Siswa_Absensi.Assign_Action;
begin
try
  with Form_Main do
    begin
    TMB0105010601030201.Action := PFile_Simpan;
    TMB01050106010301.Action   := PCommon_Daftar_Subject;
    with CB010501 do
      begin
      with Categories[5] do
        begin
        Items[1].Action := PMenu_Entry_Absensi;
        end;
      end;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_Absensi.Assign_LoginInfo;
begin
try
  with Form_Main do
    begin
    GServer_Host     := IN010301.Text;
    GServer_Database := IN010302.Text;
    GServer_UserName := IN010303.Text;
    GServer_Password := IN010304.Text;
    GUserName        := LE01010101.Text;
    GUserPassword    := LE01010102.Text;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_Absensi.HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
var
  LocalStrings: TStringList;
begin
try
  LocalStrings          := TStringList.Create;
  SOAPResponse.Position := 0;
  LocalStrings.LoadFromStream(SOAPResponse);
  // ShowMessage(LocalStrings.Text);
  FreeAndNil(LocalStrings);
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_Absensi.PCommon_Daftar_SubjectExecute(Sender: TObject);
var
  InfoServer: TInfoServer;
  LocalIndex: word;
  LocalCount: integer;
begin
try
  with HTTPRIO1 as SERVICE_ENTRY_SISWA_ABSENSIPortType do
    begin
    Assign_LoginInfo;
    InfoServer                 := TInfoServer.Create;
    InfoServer.Server_Host     := GServer_Host;
    InfoServer.Server_Database := GServer_Database;
    InfoServer.Server_Username := GServer_UserName;
    InfoServer.Server_Password := GServer_Password;
    DATA_SISWA_GURU_MAPEL_ABSENSI(InfoServer, FMasterSiswa_Combo, FMasterGuru_Combo, FMasterMapel_Combo, FMasterAbsensiStatus_Combo);
    with Form_Main do
      begin
      LocalCount := high(FMasterSiswa_Combo);
      if LocalCount > 0 then
        begin
        with IN01050106010301, Items do
          begin
          BeginUpdate;
          Clear;
          for LocalIndex := 0 to high(FMasterSiswa_Combo) do
            begin
            with FMasterSiswa_Combo[LocalIndex] do
              begin
              Add(SISWA_KODE + ' - ' + SISWA_NAMA_AWAL);
              end;
            end;
          EndUpdate;
          ItemIndex := 0;
          end;
        end;
      LocalCount := high(FMasterGuru_Combo);
      if LocalCount > 0 then
        begin
        with IN01050106010302, Items do
          begin
          BeginUpdate;
          Clear;
          for LocalIndex := 0 to high(FMasterGuru_Combo) do
            begin
            with FMasterGuru_Combo[LocalIndex] do
              begin
              Add(GURU_KODE + ' - ' + GURU_NAMA_AWAL);
              end;
            end;
          EndUpdate;
          ItemIndex := 0;
          end;
        end;
      LocalCount := high(FMasterMapel_Combo);
      if LocalCount > 0 then
        begin
        with IN01050106010303, Items do
          begin
          BeginUpdate;
          Clear;
          for LocalIndex := 0 to high(FMasterMapel_Combo) do
            begin
            with FMasterMapel_Combo[LocalIndex] do
              begin
              Add(MAPEL_KODE + ' - ' + MAPEL_NAMA);
              end;
            end;
          EndUpdate;
          ItemIndex := 0;
          end;
        end;
      LocalCount := high(FMasterAbsensiStatus_Combo);
      if LocalCount > 0 then
        begin
        with IN01050106010304, Items do
          begin
          BeginUpdate;
          Clear;
          for LocalIndex := 0 to high(FMasterAbsensiStatus_Combo) do
            begin
            with FMasterAbsensiStatus_Combo[LocalIndex] do
              begin
              Add(ABSENSI_KODE + ' - ' + ABSENSI_NAMA);
              end;
            end;
          EndUpdate;
          ItemIndex := 0;
          end;
        end;
      end;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_Absensi.PFile_SimpanExecute(Sender: TObject);
var
  DataServer:        TInfoServer;
  DataAbsensi:       TInfoAbsensi;
  DaftarDataAbsensi: TInfoDaftarAbsensi;
  InfoDate:          TXSDateTime;
begin
try
  Assign_LoginInfo;
  DataServer                 := TInfoServer.Create;
  DataAbsensi                := TInfoAbsensi.Create;
  InfoDate                   := TXSDateTime.Create;
  DataServer.Server_Host     := GServer_Host;
  DataServer.Server_Database := GServer_Database;
  DataServer.Server_Username := GServer_UserName;
  DataServer.Server_Password := GServer_Password;
  with Form_Main, HTTPRIO1 as SERVICE_ENTRY_SISWA_ABSENSIPortType do
    begin
    DataAbsensi.SISWA_ID           := FMasterSiswa_Combo[IN01050106010301.ItemIndex].ID;
    DataAbsensi.MAPEL_ID           := FMasterGuru_Combo[IN01050106010302.ItemIndex].ID;
    DataAbsensi.GURU_ID            := FMasterMapel_Combo[IN01050106010303.ItemIndex].ID;
    DataAbsensi.ABSENSI_ID         := FMasterAbsensiStatus_Combo[IN01050106010304.ItemIndex].ID;
    InfoDate.AsDateTime            := IN01050106010305.DateTime;
    DataAbsensi.ABSENSI_TGL        := InfoDate;
    DataAbsensi.ABSENSI_KETERANGAN := IN01050106010306.Text;
    SetLength(DaftarDataAbsensi, 1);
    DaftarDataAbsensi[0] := DataAbsensi;
    SISWA_SIMPAN_ABSENSI_DATASET(DataServer, DaftarDataAbsensi);
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_Absensi.PMenu_Entry_AbsensiExecute(Sender: TObject);
begin
try
  with Form_Main, TMB01050106010301 do
    begin
    Show;
    SetFocus;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

end.
